App.MainApp.module('saveDialogModule', function(saveDialogModule){
	var _savedialog = null;
	// View for Layout
   var MainView = Marionette.ItemView.extend({
		id: 'saveDialog',
      template: "#savedialog-layout-template" 
   });
	this.startWithParent = false;
	// Controller for Layout
	var Controller = Marionette.Controller.extend({
		initialize: function(options){
			if (App.debug) console.log('App.saveDialogModule Controller initialized');
			this.region = options.region
		},
		show: function() {
			if (App.debug) console.log('App.saveDialogModule Controller show invoked');
			var main_view = new MainView({});
			this.region.show(main_view);
		},
		render: function() {
			if (App.debug) console.log('App.saveDialogModule Controller show invoked');
         $('#saveDialog').wijdialog({
				title: 'Save',
            autoOpen: true,
            captionButtons: {
               refresh: { visible: false}
            }
         });
		}
	});
	
	saveDialogModule.addInitializer(function (options) {
		var defaults = {
			region: App.MainApp.saveDialogRegion
		};
		options = _.extend(defaults, options);
		if (App.debug) console.log('App.saveDialogModule addInitializer');
		saveDialogModule.Controller = new Controller({
			region: options.region
		});
		saveDialogModule.Controller.show();
		saveDialogModule.Controller.render();
   });
});

App.MainApp.saveDialogModule.on("before:start", function(){
	if (App.debug) console.log('App.saveDialogModule before:start');
});

App.MainApp.saveDialogModule.on("start", function(){
	if (App.debug) console.log('App.saveDialogModule start');
	
});

